<?php

class Layout
{
    function listOfTopMenu()
    {
        $top[ABOUT_ID]['title']     = ABOUT_TITLE;
        $top[PROGRAMME_ID]['title'] = PROGRAMME_TITLE;
        $top[PARTNER_ID]['title']   = PARTNER_TITLE;
        $top[FACULTY_ID]['title']   = FACULTY_TITLE;
        $top[NEWS_ID]['title']      = NEWS_TITLE;
        $top[TOOL_ID]['title']      = TOOL_TITLE;
        $top[FAQ_ID]['title']       = FAQ_TITLE;
        $top[CONTACT_ID]['title']   = CONTACT_TITLE;
        
        $top[ABOUT_ID]['url']       = ABOUT_URL;
        $top[PROGRAMME_ID]['url']   = PROGRAMME_URL;
        $top[PARTNER_ID]['url']     = PARTNER_URL;
        $top[FACULTY_ID]['url']     = FACULTY_URL;
        $top[NEWS_ID]['url']        = NEWS_URL;
        $top[TOOL_ID]['url']        = TOOL_URL;
        $top[FAQ_ID]['url']         = FAQ_URL;
        $top[CONTACT_ID]['url']     = CONTACT_URL;
        return $top;
    }
    
    function preparePathWeb($topmenu_id = 0,$submenu_id = 0)
    {
        $smarty 	= DRX::load("smarty");
        $topmenu = $this->listOfTopMenu();
        
        if ($topmenu_id)
        {
            $list_path[0]['url'] = APPLICATION_URL;
            $list_path[0]['title'] = HOMEPAGE_TITLE;
            
            $submenu    = new Submenu();
            $submenuInfo= $submenu->getSubmenuInfoByID($submenu_id);
            if ($submenuInfo->fetch())
            {
                $list_path[1]['title']  = $topmenu[$topmenu_id]['title'];
                $list_path[1]['url']    = APPLICATION_URL . $topmenu[$topmenu_id]['url'];
                $menu_title = $submenuInfo->menu_title;
                $last_path['title'] = $menu_title;
                $last_path['url']   = APPLICATION_URL . $topmenu[$topmenu_id]['url'] . NODE_CONTENT_ACTION . $submenu_id;
            }
            else 
            {
                $last_path['title'] = $topmenu[$topmenu_id]['title'];
                $last_path['url']   = APPLICATION_URL . $topmenu[$topmenu_id]['url'];
            }
        }
        else 
        {   //Homepage
            $last_path['url'] = APPLICATION_URL;
            $last_path['title'] = "Homepage";
        }
        $smarty->assign("list_path",$list_path);
        $smarty->assign("last_path",$last_path);
        $smarty->assign("content_title",$last_path['title']);
    }
    
	function prepareLayout($args)
	{							
	    $topmenu_id = $args['topmenu_id'];
	    $submenu_id = $args['submenu_id'];
	    $leftpane   = $args['leftpane'];
	    
	    $smarty 	= DRX::load("smarty");
	    
	    $topmenu	= new Topmenu();

		$topmenu->prepareTopMenu();

		$this->preparePathWeb($topmenu_id,$submenu_id);
	    if ($topmenu_id)
	    {
	        $topmenu = new Topmenu();
            $topmenu->prepareTopBanner($topmenu_id);
            if ($leftpane)
            {
                $smarty->assign("left_active",$submenu_id);
                $submenu	= new Submenu();
    		    $submenu->prepareLeftPane($topmenu_id);
            }
	    }
        $path_web = $smarty->fetch("public/path_web.tpl");
        $smarty->assign("path_web",$path_web);
	}
}
?>